<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>奥鹏网考系统 - 管理端登录日志</title>
    <link rel="shortcut icon" href="favicon.ico" mce_href="/favicon.ico" type="image/x-icon" />

    <link href="//openexamcdn.open.com.cn/openexam/static/Content/bootstrap.min.css" rel="stylesheet" />
    <link href="//openexamcdn.open.com.cn/openexam/static/App/vendor/jquery.datetimepicker/jquery.datetimepicker.css" rel="stylesheet" />
</head>
<body>
<div class="container">
    <div class="page-header">
        <h1>
            奥鹏网考系统 <small>管理端登录日志</small>
        </h1>
    </div>

    <form class="form-inline">
        <div class="form-group">
            <label for="txtExamSiteId">考点ID：</label>
            <input type="text" class="form-control" id="txtExamSiteId" name="examSiteId" placeholder="考点ID" />
        </div>
        <div class="form-group">
            <label for="txtLoginIp">登录IP：</label>
            <input type="text" class="form-control" id="txtLoginIp" name="loginIp" placeholder="登录IP" />
        </div>
        <div class="form-group">
            <label for="txtLoginStatus">登录状态：</label>
            <input type="text" class="form-control" id="txtLoginStatus" name="loginStatus" placeholder="登录状态" />
        </div>
        <br />
        <br />
        <div class="form-group">
            <label for="txtBeginTime">开始时间：</label>
            <div class="input-group">
                <input type="text" class="form-control datetimepicker" id="txtBeginTime" name="beginTime" placeholder="开始时间" readonly="readonly" />
                <span class="input-group-btn">
                        <button type="button" class="btn btn-default btn-sm" onclick="javascript: document.getElementById('txtBeginTime').value = null;">
                            <i class="glyphicon glyphicon-remove"></i>
                        </button>
                    </span>
            </div>
        </div>
        <div class="form-group">
            <label for="txtEndTime">结束时间：</label>
            <div class="input-group">
                <input type="text" class="form-control datetimepicker" id="txtEndTime" name="endTime" placeholder="结束时间" readonly="readonly" />
                <span class="input-group-btn">
                        <button type="button" class="btn btn-default btn-sm" onclick="javascript: document.getElementById('txtEndTime').value = null;">
                            <i class="glyphicon glyphicon-remove"></i>
                        </button>
                    </span>
            </div>
        </div>
        <button type="submit" class="btn btn-default">
            <i class="glyphicon glyphicon-search"></i>
            查询
        </button>
    </form>
    <hr />

    <h5>
        总计：<b id="logCount"></b> 条记录
    </h5>

    <table class="table table-striped table-bordered table-hover" id="adminLoginLogTable">
        <thead>
        <tr class="success">
            <th>序号</th>
            <th>主办方ID</th>
            <th>考点ID</th>
            <th>登录IP</th>
            <th>登录状态</th>
            <th>登录时间</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>

<script src="//openexamcdn.open.com.cn/openexam/static/Scripts/jquery-1.12.4.min.js"></script>
<script src="//openexamcdn.open.com.cn/openexam/static/App/vendor/jquery.datetimepicker/jquery.datetimepicker.js"></script>
<script type="text/javascript">
    function GetQueryString(name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
    }

    window.onload = function () {
        $('.datetimepicker').datetimepicker({
            lang: 'ch',
            step: 5
        });

        var examSiteId = GetQueryString('examSiteId');
        if (examSiteId)
            document.getElementById('txtExamSiteId').value = examSiteId;

        var loginIp = GetQueryString('loginIp');
        if (loginIp)
            document.getElementById('txtLoginIp').value = loginIp;

        var loginStatus = GetQueryString('loginStatus');
        if (loginStatus)
            document.getElementById('txtLoginStatus').value = loginStatus;

        var beginTime = GetQueryString('beginTime');
        if (beginTime) {
            beginTime = beginTime.replace('+', ' ');
            document.getElementById('txtBeginTime').value = beginTime;
        }

        var endTime = GetQueryString('endTime');
        if (endTime) {
            endTime = endTime.replace('+', ' ');
            document.getElementById('txtEndTime').value = endTime;
        }

        getAdminLoginLogList(examSiteId,loginIp,loginStatus,beginTime,endTime)
    };

    function getAdminLoginLogList(examSiteId,loginIp,loginStatus,beginTime,endTime) {
        var $table = $("#adminLoginLogTable");

        $.ajax({
            url:"/Home/AdminLoginLog",
            type:"POST",
            contentType:"application/x-www-form-urlencoded;charset=UTF-8",
            dataType:"json",
            data:{
                examSiteId:examSiteId,
                loginIp:loginIp,
                loginStatus:loginStatus,
                beginTime:beginTime,
                endTime:endTime
            },
            success:function (data) {
                var tbody = '';
                if(data.length > 0){
                    for(var i=0;i<data.length;i++){
                        tbody += '<tr>';
                        tbody += '<td>'+(i+1)+'</td>';
                        tbody += '<td>'+data[i].appID+'</td>';
                        tbody += '<td>'+data[i].examSiteID+'</td>';
                        tbody += '<td>'+data[i].loginIPAddress+'</td>';
                        tbody += '<td>'+data[i].loginStatus+'</td>';
                        tbody += '<td>'+data[i].loginTime+'</td>';
                        tbody += '</tr>'
                    }
                }else{
                    tbody += '<tr><td colspan="6" style="text-align: center;">未查询到数据 </td></tr>';
                }
                //总数据数
                $("#logCount").html(data.length);
                $table.find("tbody").append(tbody);
            }
        })
    }
</script>
</body>
</html>